package com.brtbeacon.demo.lot.fragment;


import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.brtbeacon.demo.lot.LotMapActivity;
import com.brtbeacon.demo.lot.R;
import com.brtbeacon.locationengine.ble.BRTLocationManager;
import com.brtbeacon.map.map3d.entity.BRTPoi;
import com.brtbeacon.map.map3d.entity.BRTPoint;
import com.brtbeacon.map.map3d.route.BRTDirectionalHint;
import com.brtbeacon.map.map3d.route.BRTMapRouteManager;
import com.brtbeacon.map.map3d.route.BRTRoutePart;
import com.brtbeacon.map.map3d.route.BRTRouteResult;
import com.brtbeacon.map.map3d.utils.BRTConvert;
import com.brtbeacon.mapdata.BRTLocalPoint;

import java.util.List;

/**
 * 车辆导航信息展示面板
 */
public class ParkingNavigateHintFragment extends ParkingBaseFragment {

    public TextView tvHint;
    public TextView tvRemainLength;
    public ImageView ivDirection;

    public TextView getTvHint() {
        return tvHint;
    }

    public TextView getTvRemainLength() {
        return tvRemainLength;
    }

    public ImageView getIvDirection() {
        return ivDirection;
    }

    public ParkingNavigateHintFragment() {

    }

    public static ParkingNavigateHintFragment newInstance() {
        ParkingNavigateHintFragment fragment = new ParkingNavigateHintFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.bb_fragment_parking_navigate_hint, container, false);
        tvHint = rootView.findViewById(R.id.tv_hint);
        tvRemainLength = rootView.findViewById(R.id.tv_remain_length);
        ivDirection = rootView.findViewById(R.id.iv_direction);
        return rootView;
    }

    /*
    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        LotMapActivity activity = (LotMapActivity) getActivity();
        BRTLocalPoint lastLocation = activity.getLastLocation();
        if (lastLocation != null) {
            updateRouteHint(BRTPoint.from(lastLocation));
        }
        //updateRouteHint(activity.getLastLocation());
    }
    */

    /*
    private void updateRouteHint(BRTPoint lp) {
        LotMapActivity activity = (LotMapActivity) getActivity();
        BRTRouteResult routeResult = activity.getRouteResult();
        if(routeResult == null)
            return;
        BRTRoutePart part = routeResult.getNearestRoutePart(lp);

        if (part != null) {
            List<BRTDirectionalHint> hints = part.getRouteDirectionalHint();
            BRTDirectionalHint hint = part.getDirectionalHintForLocationFromHints(lp, hints);
            activity.onNavigateHint(lp, routeResult, part, hint, this);
        }
    }
    */

    /*
    @Override
    public void didUpdateLocation(BRTLocationManager BRTLocationManager, BRTLocalPoint tyLocalPoint) {
        updateRouteHint(new BRTPoint(tyLocalPoint.getFloor(), BRTConvert.toLatLng(tyLocalPoint.getX(), tyLocalPoint.getY())));
    }
    */

}
